package Controller.SCServlet;

import Dao.CourseDao;
import Dao.StudentDao;
import bean.Course;
import bean.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/sc_sd")
public class sc_sd extends HttpServlet {
    StudentDao stuDao = new StudentDao();
    CourseDao courseDao = new CourseDao();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ArrayList<Student> list1 = stuDao.selectAll();
        ArrayList<Course> list2 = courseDao.selectAll();
        req.setAttribute("student_list",list1);
        req.setAttribute("course_list",list2);
        req.getRequestDispatcher("SCInfoAdd.jsp").forward(req,resp);
    }
}